<template>
  <view class="page-body">
        <view class="uni-list-cell" hover-class="uni-list-cell-hover">
            <view class="uni-list-cell-navigate mainpage-color-gray">
                <view>
                    <image class="uni-list-cell-navigate-image" src="../../../static/qianbao.png"></image>
                    微信通知
                </view>
                <view class="uni-list-cell-a uni-list-cell-pd">
                    <switch class="class-switch" v-bind:checked="formData.webchat"  @change="webchat" />
                </view>
            </view>
        </view>
        <view class="uni-list-cell" hover-class="uni-list-cell-hover">
            <view class="uni-list-cell-navigate mainpage-color-gray">
                <view>
                    <image class="uni-list-cell-navigate-image" src="../../../static/qianbao.png"></image>
                    微信开课通知
                </view>
                <view class="uni-list-cell-a uni-list-cell-pd">
                	<switch class="class-switch" v-bind:checked="formData.openclass" @change="openclass"  />
                </view>
            </view>
        </view>
        <view class="uni-list-cell" hover-class="uni-list-cell-hover">
            <view class="uni-list-cell-navigate mainpage-color-gray">
                <view>
                    <image class="uni-list-cell-navigate-image" src="../../../static/qianbao.png"></image>
                    短信通知
                </view>
                <view class="uni-list-cell-a uni-list-cell-pd">
                	<switch class="class-switch" v-bind:checked="formData.msg" @change="msg"  />
                </view>
            </view>
        </view>
        <view class="uni-list-cell" hover-class="uni-list-cell-hover">
            <view class="uni-list-cell-navigate mainpage-color-gray">
                <view>
                    <image class="uni-list-cell-navigate-image" src="../../../static/qianbao.png"></image>
                    签到通知短信
                </view>
                <view class="uni-list-cell-a uni-list-cell-pd">
                	<switch class="class-switch" v-bind:checked="formData.signin" @change="signin"  />
                </view>
            </view>
        </view>
        <view class="uni-list-cell" hover-class="uni-list-cell-hover">
            <view class="uni-list-cell-navigate mainpage-color-gray">
                <view>
                    <image class="uni-list-cell-navigate-image" src="../../../static/qianbao.png"></image>
                    课前通知短信
                </view>
                <view class="uni-list-cell-a uni-list-cell-pd">
                	<switch class="class-switch" v-bind:checked="formData.beforeclass" @change="beforeclass"  />
                </view>
            </view>
        </view>
		<view><text style="color: #DDDDDD; margin-left: 20px;">我们提供免费100条短信，用完可以继续购买</text></view>
    </view>
</template>

<script>
export default {
    data() {
        return {
            formData: {
                webchat: false,
                openclass: true,
                msg: false,
                signin: true,
                beforeclass: true
            }
        };
    },
    methods: {
        getsetting: function() {
            uni.request({
                url: '/api/setnotify',
                method: 'POST',
                data: data,
                success: data => {
                    uni.stopPullDownRefresh();
                    if (data.statusCode == 200) {
                        this.stulist = data.data;
                    }
                },
                fail: (data, code) => {
                    console.log('fail' + JSON.stringify(data));
                }
            });
        },

        setnotify: function() {
            let data = formData;
            uni.request({
                url: '/api/setnotify',
                method: 'POST',
                data: data,
                success: data => {
                    uni.stopPullDownRefresh();
                    if (data.statusCode == 200) {
                        this.stulist = data.data;
                    }
                },
                fail: (data, code) => {
                    console.log('fail' + JSON.stringify(data));
                }
            });
        },
        webchat: function(e) {
            this.formData.openwebchat = e.detail.value;
            console.log(e.detail.value);
        },
        openclass: function() {
            this.formData.openclass = e.detail.value;
            console.log(e.detail.value);
        },
        msg: function() {
            this.formData.msg = e.detail.value;
            console.log(e.detail.value);
        },
        signin: function() {
            this.formData.signin = e.detail.value;
            console.log(e.detail.value);
        },
        beforeclass: function() {
            this.formData.beforeclass = e.detail.value;
            console.log(e.detail.value);
        }
    }
};
</script>

<style scoped >
@import '../../../common/uni.css';
.uni-list-cell-navigate-image {
    width: 30px;
    height: 30px;
}

.class-main-page-right-arraws {
    width: 30px;
    height: 30px;
}

.uni-list-cell-a {
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
}
.class-switch {
}
.mainpage-color-gray {
    color: #8f8f94;
    height: 100px;
}
</style>
